package com.tjmc.tiomsresource.service.impl;

import com.tjmc.tiomscore.dao.TiCardMapper;
import com.tjmc.tiomscore.dao.TranPtnHwCrdMapper;
import com.tjmc.tiomscore.model.TranPtnHwCrd;
import com.tjmc.tiomsresource.parser.CMCrdParser;
import com.tjmc.tiomsresource.service.CMCrdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.List;

/**
 * @author Luc
 * @version 1.0
 * @date 2020-05-20 15:41
 */
@Service("cmCrdService")
public class CMCrdServiceImpl extends CMSuperServiceImpl<TranPtnHwCrd> implements CMCrdService {

    @Autowired
    private CMCrdParser cmCrdParser;
    @Autowired
    private TranPtnHwCrdMapper tranPtnHwCrdMapper;
    @Autowired
    private TiCardMapper tiCardMapper;

    @Override
    public CMCrdParser getParser() {
        return cmCrdParser;
    }

    @Override
    public TranPtnHwCrdMapper getMapper() {
        return tranPtnHwCrdMapper;
    }

    @Override
    public boolean saveTranPtnHwDataToDB(List<File> xmlFiles) {
        return this.saveTranPtnHwDataToDB(xmlFiles, "CRD");
    }

    @Override
    public void buildTiCardToDB() {
        tiCardMapper.truncateTable();
        tiCardMapper.insertDataFromTranPtnCard();
    }
}
